package cn.iocoder.yudao.module.product.spu.vo;

import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Schema(description = "用户 APP - 商家的产品 SPU 明细 Response VO")
@Data
public class AppShopProductSpuDetailRespVO extends AppProductSpuDetailRespVO {

    @Schema(description = "成本价格，单位使用：分", requiredMode = Schema.RequiredMode.REQUIRED, example = "59")
    @JsonIgnore(value = false)
    private Integer costPrice; // 需要返回成本价给前端商户看到以便修改
    @Schema(description = "成本价格，单位使用：元", requiredMode = Schema.RequiredMode.REQUIRED, example = "0.01")
    @JsonIgnore(value = false)
    private String costPriceYuan;

    @JsonIgnore(value = false)
    @Override
    public int getCostPrice() {
        if (costPrice == null || costPrice <= 0) {
            return 0;
        }
        return costPrice;
    }

    @JsonIgnore(value = false)
    @SuppressWarnings("unused")
    public String getCostPriceYuan() {
        return MoneyUtils.fenToYuanStr(NumberUtil.nullToZero(costPrice));
    }

}
